package com.ps.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ps.pojo.PoleInfo;
import com.ps.service.PoleInfoService;
import com.ps.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 杆塔信息表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2020-12-18
 */
@RestController
@RequestMapping("/gn/tggl")
public class PoleInfoController {
    @Resource
    private PoleInfoService poleInfoService;
    @GetMapping("/getAll")
    @ResponseBody
    public Result getAll(Integer page, Integer limit, PoleInfo poleInfo){
        Page<PoleInfo> all = poleInfoService.getAll(page, limit, poleInfo);
        return Result.success(all);
    }
    @PostMapping("/add")
    @ResponseBody
    public Result add(String qian,Integer num){
        poleInfoService.add(qian,num);
        Result result=new Result();
        result.setMsg("添加成功！");
        return result;
    }
    @PostMapping("/del")
    @ResponseBody
    public Result del(Integer id){
        Result result=new Result();
        if (poleInfoService.removeById(id)){
            result.setMsg("删除成功！");
        }else {
            result.setMsg("删除失败！");
        }
        return result;
    }
    @PostMapping("/update")
    @ResponseBody
    public Result update(Integer id,Integer isstart,Integer lineid){
        Result result=new Result();
        if (poleInfoService.update(id,isstart,lineid)){
            result.setMsg("修改成功！");
        }else {
            result.setMsg("修改失败！");
        }
        return result;
    }
}

